/*
 * Licensed to the anubis
 *
 * Copyright (c) 2023 .
 * All rights reserved.
 * 项目名称：anubis-demo-web
 * 项目描述：基于spring5的spring-mvc新特性
 * 版权说明：本软件属XXX有限公司所有，在未获得XXX有限公司正式授权情况下，任何企业和个人，不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
 */
package com.anubis.demo.web.controller;

import com.anubis.demo.pojo.bo.Stock;
import com.anubis.demo.pojo.bo.StockSymbol;
import com.anubis.demo.service.impl.StockServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/stocks")
public class StockController {

    @Autowired
    private StockServiceImpl stockService;

    @GetMapping
    private String getStocks(Model model) {
        List<Stock> stocks = stockService.getAllStocks();
        model.addAttribute("stocks", stocks);
        model.addAttribute("stockSymbol", new StockSymbol());
        return "stocks";
    }
}
